package controllers;

import play.*;
import play.data.validation.Required;
import play.mvc.*;
import java.util.*;

import javax.persistence.Entity;

import org.apache.commons.mail.EmailException;

import models.*;

@With(Secure.class)
// this class is used for the login, Doaa El-Hawary
public class Tags extends Controller {

	public static void index() {
		render();
	}


	/**
	 * Method to render all tags in a certain topic
	 * 
	 * 
	 * 
	 * @author Caroline Tawfik
	 * @version 2011.0504
	 * @category Helper
	 * @param long topicId: the topic to find all the tags in
	 * @return void
	 **/
	public static void viewTagsInTopic(long topicID) {

		Topic topic = Topic.findById(topicID);
		List tags = new LinkedList();
		tags = topic.getTags();
		render(tags);
	}

	/**
	 * Method to render all tags in a certain Organization
	 * 
	 * 
	 * 
	 * @author Caroline Tawfik
	 * @version 2011.0504
	 * @category Helper
	 * @param long organizationId: the Organization to find all the tags in
	 * @return void
	 **/
	public static void viewTagsInOrganization(long orgID) {

		Organization organization = Organization.findById(orgID);
		List tags = new LinkedList();
		tags = organization.getTags();
		render(tags);
	}

	/**
	 * Method to render all tags in a certain Idea
	 * 
	 * 
	 * 
	 * @author Caroline Tawfik
	 * @version 2011.0504
	 * @category Helper
	 * @param long ideaId: the idea to find all the tags in
	 * @return void
	 **/
	public static void viewTagsInIdea(long ideaID) {
		Idea idea = Idea.findById(ideaID);
		List tags = idea.getTags();
		render(tags);
	}

	/**
	 * Method to render all tags in a certain Entity
	 * 
	 * 
	 * 
	 * @author Caroline Tawfik
	 * @version 2011.0504
	 * @category Helper
	 * @param long entityId: the Entity to find all the tags in
	 * @return void
	 **/
	public static void viewTagsInEntity(long entityID) {

		Eentity entity = Eentity.findById(entityID);
		List tags = new LinkedList();
		tags = entity.getTags();
		render(tags);
	}

	/**
	 * Method to render all tags in the system
	 * 
	 * 
	 * 
	 * @author Caroline Tawfik
	 * @version 2011.0504
	 * @category helper
	 * @param nothing
	 * @return void
	 **/

	public static void viewAllTags() {
		List tags = Tag.findAll();
		render(tags);
	}

}
